<?php
/**
 * @file
 * Defines all locales available in 'GreenInDeed' and retreives the current
 * user's locale.
 *
 * Usage:
 *  - A page that wants to get the list of available locales or retreive the
 *    current user's locale should include/require this page once and only once.
 *
 * Parameter(s):
 *  - None.
 *
 * Global variable(s) set:
 *  - $locale_user : Locale of the current user.
 *
 * Global variable(s) unset:
 *  - None.
 *
 * Exception(s):
 *  - None.
 *
 * This file includes/requires:
 *  - None.
 */

// constant(s) =================================================================
//! Index of locale code in locale information.
define("LOCALE_INDEX_ll_CC", 0);
//! Index of country code in locale.
define("LOCALE_INDEX_DESCRIPTION", 1);
//! Available locales.
$LOCALES = array(
  array("en_US", "English (US)"),
  array("id_ID", "Bahasa Indonesia")
);

//! Index of the default locale.
define("DEF_LOCALE", 0);

//! Locale parameter name.
define("PARAM_LOCALE", "gid_locale");


// implementation ==============================================================
// set to default locale
$locale_user = $LOCALES[DEF_LOCALE][LOCALE_INDEX_ll_CC];

if (isset($_GET[PARAM_LOCALE])) {
  // retreive locale from get parameter
  $locale_user = $_GET[PARAM_LOCALE];
} else {
  // TODO: Retreive facebook locale.
  //       Cannot achieve this currently because the 'GET' parameters are not
  //       passed to 'fb_user_locale.php'.
  /*
  require_once $PATH_COMMON . "php/fb_user_locale.php";
  if (isset($fb_locale)) {
    // set to facebook locale
    $locale_user = $fb_locale;
  }
  */
}
?>
